package chixing.day16.class23;

import java.io.FileWriter;
import java.io.IOException;
import java.io.Writer;

public class WriterDemo {
    public static void main(String[] args) {
        //创建字符写入流（抽象父类 Writer）
    Writer w=null;
        try {
            w=new FileWriter("D:\\a\\a.txt");
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
        //2 写
        try {
            w.write("hello world");
            w.flush();//刷新缓冲区
        } catch (IOException e) {
            throw new RuntimeException(e);
        }finally{ //关闭流
            try {
                w.close();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
    }
}
